package vnc;

import javax.swing.JOptionPane;

import vnc.JDStatisticsTakerLoader;

import vnc.JDPacketAnalyzerLoader;

import jpcap.NetworkInterface;

public class Vnc {
	
	public static VncFrame window;
	
	public static void main(String args[]) throws Exception{
		
		try{
			Class.forName("jpcap.JpcapCaptor");
			NetworkInterface[] devices=jpcap.JpcapCaptor.getDeviceList();
			if(devices.length==0){
				JOptionPane.showMessageDialog(null,"No network interface found.\nYou need to be admin/su to capture packets.",
						"Warning",JOptionPane.WARNING_MESSAGE);
			}
		}catch(ClassNotFoundException e){
			JOptionPane.showMessageDialog(null,"Cannot find Jpcap. Please install Jpcap.",
					"Error",JOptionPane.ERROR_MESSAGE);
			System.exit(-1);
		}catch(UnsatisfiedLinkError e){
			JOptionPane.showMessageDialog(null,"Cannot find Jpcap and/or libpcap/WinPcap.\n Please install Jpcap and libpcap/WinPcap.",
					"Error",JOptionPane.ERROR_MESSAGE);
			System.exit(-1);
		}
		
		JDPacketAnalyzerLoader.loadDefaultAnalyzer();
		JDStatisticsTakerLoader.loadStatisticsTaker();
		
		openNewWindow();
		
	}
	
	public static void openNewWindow(){
		window = new VncFrame();
	}
}